

import java.util.Scanner;

public class Demo9 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int year = scanner.nextInt();
        int month = scanner.nextInt();
        int day = scanner.nextInt();
        int date = 0;

        switch (month){
            case 12:
                date+=30;
            case 11:
                date+=31;
            case 10:
                date+=30;
            case 9:
                date+=31;
            case 8:
                date+=31;
            case 7:
                date+=30;
            case 6:
                date+=31;
            case 5:
                date+=30;
            case 4:
                date+=31;
            case 3:
                if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
                    date=date+29;
                } else {
                    date=date+28;
                }
            case 2:
                date+=31;
            case 1:
                date+=day;

        }
        System.out.println(date);
        scanner.close();
    }
}

